package batframework.mvc.render;

import java.io.IOException;
import java.io.InputStream;

import batframework.code.util.IoUtils;


/**
 * 
 * @author bmyues
 *
 */
public class StreamRender extends AbstractRender
{
	
	private long length;
	
	private byte[] data;
	
	public void render()
	{
		try {
			IoUtils.write(data, response.getOutputStream());
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public StreamRender(InputStream inputStream)
	{
		this.data = IoUtils.getBytes(inputStream);
		this.setLength(this.data.length);
	}
	
	public StreamRender()
	{
		super();
	}
	
	public long getLength()
	{
		return length;
	}
	
	public void setLength(long length)
	{
		this.length = length;
	}
	
}
